package org.fatmansoft.teach.repository;

import org.apache.poi.ss.formula.functions.T;
import org.fatmansoft.teach.models.Student;
import org.fatmansoft.teach.models.Teacher;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface TeacherRepository extends JpaRepository<Teacher, Integer> {

    @Query(value = "select max(teacherId) from Teacher  ")
    Integer getMaxId();

    Teacher findByPersonNum(String num);

    Teacher findByPersonName(String name);

    Optional<Teacher> findByPersonPersonId(Integer id);


    @Query(value = "from Teacher where ?1='' or person.num like %?1% or person.name like %?1% ")
    List<Teacher> findTeacherListByNumName(String numName);


    Optional<Teacher> findTeacherByPersonNum(String teacherId);
}
